<template>
  <div>
    <!-- 关注审核列表 -->
    <div class="tabNav">
      <router-link to="/index">
        <img :src="require('/src/assets/img/sidebar1.png')" />首页
      </router-link>
      <b class="colors">/<img :src="require('/src/assets/img/service.png')" />关注管理</b>
      <b><span class="fenge">/</span>审核列表</b>
    </div>
    <el-card class="cardTits" shadow="hover">
      <div class="subject-title">
        <div class="query">
          <div class="query-input">
            <el-input
              placeholder="姓名/手机号/身份证"
              v-model="searchVal"
            ></el-input>
          </div>
          <div class="query-select">
            <el-select v-model="selectValue" placeholder="请选择">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </div>
          <el-button class="query-btn" @click="getAlreadyList" type="primary">查询</el-button>
        </div>
      </div>
      <el-table
        :data="tableData"
        stripe
        style="width: 100%"
        ref="multipleTable"
        @sort-change="sortChange"
      >
        <el-table-column width="60"> </el-table-column>
        <el-table-column prop="legalName" sortable="custom" label="姓名" width=""> </el-table-column>
        <el-table-column prop="legalIdcard" sortable="custom" label="身份证号" width="180">
        </el-table-column>
        <el-table-column prop="legalPhone" sortable="custom" label="手机号" width="">
        </el-table-column>
        <el-table-column prop="createTime" sortable="custom" label="申请关注时间" width="">
          <template #default="item">
            {{ format("yyyy-MM-dd hh:mm:ss", new Date(item.row.createTime)) }}
          </template>
        </el-table-column>
        <el-table-column
          prop="isBusiness"
          align="center"
          label="是否已办理个体工商户"
          width=""
        >
          <template #default="item">
            {{ item.row.isBusiness == 1 ? '是' : '否' }}
          </template>
        </el-table-column>
        <el-table-column prop="examineStatus" align="center" label="审核状态" width="">
          <template #default="item">
            {{ processStatus[item.row.examineStatus] }}
          </template>
        </el-table-column>
        <el-table-column label="操作" class-name="editor">
          <template #default="item">
            <router-link
              :to="{
                name: 'ToexamineDetails',
                query: { id: item.row.id, businessId: item.row.selfBusinessId },
              }"
            >
              <el-button type="text">审核</el-button>
            </router-link>
          </template>
        </el-table-column>
      </el-table>

      <el-pagination
        v-if="tableData.length > 0"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="arrPage"
        :page-size="selectPage"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "ToexamineFollow",
  data() {
    return {
      orderByZH: false,
      orderByAsc: false,
      orderByColume: 'createTime',
      searchVal: "", // 查询条件
      total: 1, // 总条数
      arrPage: [10, 20], // 每页条数
      selectPage: 10, // 每页选中条数
      currentPage: 1,
      processStatus: {
        0: '待审核',
        1: '审核通过',
        2: '审核未通过'
      },
      options: [{
        value: '',
        label: '全部'
      }, {
        value: '0',
        label: '待审核'
      }, {
        value: '2',
        label: '未通过'
      }],
      selectValue: '',
      tableData: [],
    };
  },
  components: {},
  activated() {
    this.getAlreadyList()
  },
  methods: {
    handleCurrentChange(d) {
      // 分页切换回调
      this.currentPage = d
      this.getAlreadyList()
    },
    handleSizeChange(d) {
      // 分页切换每页条数回调
      this.selectPage = d
      this.getAlreadyList()
    },
    getAlreadyList() {
      // 获取列表信息
      this.$http({
        url: "/api/quick/attention/selectReviewedAttentions",
        method: "post",
        headers: {
          "Content-Type": "application/json",
        },
        data: {
          mixedStr: this.searchVal,
          examineStatus: this.selectValue,
          pageNum: this.currentPage,
          pageSize: this.selectPage,
          orderByAsc: this.orderByAsc, // 是否正序
          orderByColume: this.orderByColume, // 排序字段
          orderByZH: this.orderByZH, // 是否汉字
        },
      }).then((data) => {
        if (data.code == 0) {
          this.tableData = data.result.list
          this.total = data.result.total
        }
      });
    },
    sortChange(d) {
      // 监听排序
      if(d.prop == null) {
        // 默认排序方式
        this.orderByZH = false
        this.orderByAsc = false
        this.orderByColume = 'createTime'
      }else {
        let orderByZH = false
        if(d.prop == "legalName") {
          orderByZH = true
        }
        this.currentPage = 1
        this.selectPage = 10
        let orderByAsc = d.order == "descending" ? false : true
        this.orderByZH = orderByZH
        this.orderByAsc = orderByAsc
        this.orderByColume = d.prop
      }
      this.getAlreadyList()
    },
  },
};
</script>
